﻿using System;
using System.Collections.Generic;
using System.Text;
using MbUnit.Framework;
using MyTestRunner.Infrastructure;
using System.Reflection;

namespace MyTestRunner.Tests.Infrastructure
{
    /// <summary>
    /// Specifies how getting method info from the reflection helper should behave.
    /// </summary>
    [TestFixture]
    [TestsOn(typeof(ReflectionHelper))]
    public class WhenGettingMethod
    {
        private void TestMethod() { }

        /// <summary>
        /// Given that the method exists the methodinfo instance should be returned.
        /// </summary>
        [Test]
        public void ShouldBeAbleToGetMethodInfoGivenMethodExists()
        {
            MethodInfo actual = ReflectionHelper.GetMethod(this.TestMethod);
            MethodInfo expected = this.GetType().GetMethod("TestMethod", BindingFlags.Instance | BindingFlags.NonPublic);
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        /// Given that the argument is null the method should throw an argument null exception.
        /// </summary>
        [Test]
        [ExpectedArgumentNullException]
        public void ShouldThrowGivenArgumentIsNull()
        {
            ReflectionHelper.GetMethod(null);
        }
    }
}
